package com.ai.mall.enums;

public enum OrderStatus {
    PENDING_PAYMENT(0, "待付款"),
    PENDING_SHIPMENT(1, "待发货"),
    PENDING_RECEIPT(2, "待收货"),
    PENDING_REVIEW(3, "待评价"),
    COMPLETED(4, "已完成"),
    CANCELLED(5, "已取消");

    private final int status;
    private final String statusLabel;

    OrderStatus(int status, String statusLabel) {
        this.status = status;
        this.statusLabel = statusLabel;
    }

    public int getStatus() {
        return status;
    }

    public String getStatusLabel() {
        return statusLabel;
    }

    // 根据状态码获取枚举实例的方法
    public static OrderStatus fromStatus(int status) {
        for (OrderStatus orderStatus : OrderStatus.values()) {
            if (orderStatus.getStatus() == status) {
                return orderStatus;
            }
        }
        throw new IllegalArgumentException("无效的订单状态码: " + status);
    }
}

